package org.lc.stk.web.dto.user;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.Set;

@Data
@Schema(description = "批量操作请求")
public class BulkOperationRequest {

    @NotNull(message = "操作类型不能为空")
    @Schema(description = "操作类型（ASSIGN_ROLES-分配角色, DELETE-删除用户）", required = true)
    private OperationType operationType;

    @NotEmpty(message = "用户ID列表不能为空")
    @Schema(description = "用户ID列表", required = true)
    private Set<Integer> userIds;

    @Schema(description = "角色ID列表（分配角色时必填）")
    private Set<Integer> roleIds;

    public enum OperationType {
        ASSIGN_ROLES,
        DELETE
    }

    public void validate() {
        if (operationType == OperationType.ASSIGN_ROLES && (roleIds == null || roleIds.isEmpty())) {
            throw new IllegalArgumentException("分配角色操作时，角色ID列表不能为空");
        }
    }
}